$OpenBSD: patch-Makefile,v 1.3 2017/05/12 14:38:18 benoit Exp $

Generate shared libraries correctly.

Index: Makefile
--- Makefile.orig
+++ Makefile
@@ -18,6 +18,7 @@ FLOOKUPLDFLAGS = libfoma.a -lz
 CFLAGS = -O3 -Wall -D_GNU_SOURCE -std=c99 -fvisibility=hidden -fPIC
 FOMAOBJS = foma.o stack.o iface.o lex.interface.o
 LIBOBJS = int_stack.o define.o determinize.o apply.o rewrite.o lexcread.o topsort.o flags.o minimize.o reverse.o extract.o sigma.o io.o structures.o constructions.o coaccessible.o utf8.o spelling.o dynarray.o mem.o stringhash.o trie.o lex.lexc.o lex.yy.o lex.cmatrix.o regex.tab.o
+SHLIBOBJS = $(LIBOBJS:.o=.so)
 
 all: libfoma foma flookup cgflookup
 
@@ -64,10 +65,10 @@ LIBS = $(SHAREDLIBV) $(STATICLIB)
 
 libfoma: $(SHAREDLIBV)
 
-$(SHAREDLIBV): $(LIBOBJS)
+$(SHAREDLIBV): $(LIBOBJS) $(SHLIBOBJS)
 	$(AR) $(ARFLAGS) $(STATICLIB) $(LIBOBJS)
 	$(RANLIB) $(STATICLIB)
-	$(CC) $(CFLAGS) -shared -Wl,$(DFLAG),$(SHAREDLIBM) -o $(SHAREDLIBV) $(LIBOBJS) $(LDFLAGS)
+	$(CC) $(CFLAGS) -shared -o $(SHAREDLIBV) $(SHLIBOBJS) $(LDFLAGS)
 
 install: foma libfoma
 	-@if [ ! -d $(exec_prefix) ]; then mkdir -p $(exec_prefix); fi
@@ -81,14 +82,15 @@ install: foma libfoma
 	cd $(libdir); chmod 755 $(LIBS); \
 	if test -f $(libdir)/$(SHAREDLIB); then rm  $(libdir)/$(SHAREDLIB); fi
 	if test -f $(libdir)/$(SHAREDLIBM); then rm  $(libdir)/$(SHAREDLIBM); fi
-	cd $(libdir); ln -s $(SHAREDLIBV) $(SHAREDLIB); cd $(libdir);	\
-	ln -s $(SHAREDLIBV) $(SHAREDLIBM); (ldconfig || true)		\
-	>/dev/null 2>&1; \
 
 $(OBJS): foma.h
 
 .c.o:
 	$(CC) $(CFLAGS) -c $< -o $@
+
+.SUFFIXES: .so
+.c.so:
+	$(CC) $(CFLAGS) -fPIC -c $< -o $@
 
 lex.yy.c: regex.l regex.tab.h
 	$(LEX) regex.l
